package com.wrs.examsystem.util.wheel;

import com.wrs.examsystem.entity.Student;
import com.wrs.examsystem.entity.Teacher;
import com.wrs.examsystem.entity.User;
import com.wrs.examsystem.entity.bean.EnrollBean;
import com.wrs.examsystem.entity.bean.LoginBean;
import com.wrs.examsystem.util.MD5Util;

/**
 * @author 王荣升
 * @version 1.0
 */
public class UserUtil {
    public static User loginBeanInvertUser(LoginBean loginBean){
        User user = new User();
        user.setUsername(loginBean.getUsername());
        user.setPassword(loginBean.getPassword());
        user.setUserType(loginBean.getUserType());
        return user;
    }
    public static User enrollInvertUser(EnrollBean enrollBean){
        User user = new User();
        user.setUserType(enrollBean.getUserType());
        user.setUsername(enrollBean.getNickname());
        user.setPassword(MD5Util.md5(enrollBean.getPassword()));

        return user;
    }
    public static Student enrollInvertStudent(EnrollBean enrollBean){
        Student student = new Student();
        student.setStudentNumber(enrollBean.getNumber());
        student.setStudentName(enrollBean.getName());
        student.setStudentClass(enrollBean.getClasses());
        student.setStudentSex(enrollBean.getSex().equals("男") ? 0:1);
        return student;
    }

    public static Teacher enrollInvertTeacher(EnrollBean enrollBean){
        Teacher teacher = new Teacher();
        teacher.setTeacherNumber(enrollBean.getNumber());
        teacher.setTeacherName(enrollBean.getName());
        teacher.setTeacherSex(enrollBean.getSex().equals("男") ? 0:1);
        return teacher;
    }
}
